﻿using PracticalExamples.Util;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PracticalExamples.获取PC麦克风声音
{
    /// <summary>
    /// GetPCAudio.xaml 的交互逻辑
    /// </summary>
    public partial class GetPCAudio : Window
    {
        NAudioRecorder nar;
        private VolumeInfo vInfo = new VolumeInfo();

        
        public GetPCAudio()
        {
            InitializeComponent();
            nar = new NAudioRecorder();
            nar.SetFileName(@"d:\aa1.wav");
            nar.SetCurrentMicVolume(100);
            InitializeSomething();
        }

        private void InitializeSomething()
        {
            /*List<int> selectVolume = new List<int>();
            selectVolume.Add(0);
            selectVolume.Add(10);
            selectVolume.Add(20);
            selectVolume.Add(40);
            selectVolume.Add(60);
            selectVolume.Add(80);
            selectVolume.Add(100);
            cb_volume.ItemsSource = selectVolume;
            cb_volume.SelectedIndex = cb_volume.Items.Count - 1;

            *//*BindingOperations.SetBinding(tBox_volume, TextBox.TextProperty, new Binding() { Source = vInfo, Path = new PropertyPath("Volume") });
            BindingOperations.SetBinding(cb_volume, ComboBox.TextProperty, new Binding() { Source = vInfo, Path = new PropertyPath("Volume") });*//*

            tBox_volume.Text = nar.GetCurrentMicVolume().ToString();*/
        }

        private void btn_start_Click(object sender, RoutedEventArgs e)
        {
            nar.StartRec();
            //nar.StartSpeaker();
        }

        private void btn_stop_Click(object sender, RoutedEventArgs e)
        {
            nar.StopRec();
            //nar.StopSpeaker();
        }

        private void tBox_volume_TextChanged(object sender, TextChangedEventArgs e)
        {
            //nar.SetCurrentMicVolume(vInfo.Volume);
            int num = nar.GetCurrentMicVolume();
        }
    }
}
